import jsonp from 'common/js/jsonp';
import axios from 'common/js/axios';
import { commonParams, options } from './config';

// 说明:调用此接口 , 可获取 banner( 轮播图 ) 数据
// 可选参数: type : 资源类型,对应以下类型,默认为 0 即PC
// 0: pc, 1: android, 2: iphone, 3: ipad
export function getSliderList() {
  let data = { type: 1 };
  return axios.get('/banner', { params: data });
}

// 获取推荐列表
export function getRecommendList() {
  let data = { limit: 30 };
  return axios.get('/personalized', { params: data });
}

// 获取歌单详情
export function getAlbumDetail(id) {
  let data = { id };
  return axios.get('/playlist/detail', { params: data });
}

// jsonp使用样例
export function getTopList() {
  const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg';
  const data = Object.assign({}, commonParams, {
    uin: 0,
    needNewCode: 1,
    platform: 'h5',
  });
  return jsonp(url, data, options);
}
